package com.lyh.hkcloud.util.http;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.PersistentCookieStore;
import com.lyh.hkcloud.util.base.MainApplication;
import cz.msebera.android.httpclient.cookie.Cookie;

import java.util.List;

/**
 * Created by Spark
 */
public class CookieUtils {
    public static PersistentCookieStore cookieStore;

    /**
     * 设置cookie
     */
    public static void setCookie(AsyncHttpClient client) {
        if(cookieStore==null && MainApplication.getInstance() != null) {
            cookieStore = new PersistentCookieStore(MainApplication.getInstance().getApplicationContext());
        }
        client.setCookieStore(cookieStore);
    }

    public static List<Cookie> getCookie(AsyncHttpClient client) {

        List<Cookie> cookies = cookieStore.getCookies();
        return cookies;
    }

}
